-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't consider arrays as a special case in DifferentiateVarDecl #1164
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1164 +/- ##
==========================================
- Coverage 94.55% 94.55% -0.01%
==========================================
Files 51 51
Lines 8923 8919 -4
==========================================
- Hits 8437 8433 -4
Misses 486 486
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
} | ||
if (promoteToFnScope) { | ||
if (promoteToFnScope) | ||
if (const auto* AT = dyn_cast<ArrayType>(VDType)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "clang::dyn_cast" is directly included [misc-include-cleaner]
if (const auto* AT = dyn_cast<ArrayType>(VDType))
^
@@ -410,12 +410,13 @@ namespace clad { | |||
|
|||
Expr* VisitorBase::getZeroInit(QualType T) { | |||
// FIXME: Consolidate other uses of synthesizeLiteral for creation 0 or 1. | |||
if (T->isVoidType()) | |||
if (T->isVoidType() || isa<VariableArrayType>(T)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "clang::VariableArrayType" is directly included [misc-include-cleaner]
lib/Differentiator/VisitorBase.cpp:28:
- #include <numeric>
+ #include <clang/AST/Type.h>
+ #include <numeric>
return Zero.get(); | ||
if ((T->isScalarType() || T->isPointerType()) && !T->isReferenceType()) | ||
return ConstantFolder::synthesizeLiteral(T, m_Context, /*val=*/0); | ||
if (isa<ConstantArrayType>(T)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "clang::ConstantArrayType" is directly included [misc-include-cleaner]
if (isa<ConstantArrayType>(T)) {
^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
This PR improves the support for array types in
getZeroInit
and simplifiesDifferentiateVarDecl
using that change.Note: most of the diff comes from the change in indentation